GtkGrid: Tweak size allocation
authorMatthias Clasen <mclasen@redhat.com>
Sat, 16 Mar 2013 03:10:39 +0000 (23:10 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 16 Mar 2013 03:38:30 +0000 (23:38 -0400)
If there are rows that contain only spanning children,
our algorithm was unnecessarily distributing extra space
to the other rows, even if they contain only non-expanding
children.

We improve the behaviour by treating rows containing only
spanning children as expanding.

gtk/gtkgrid.c

index 571f8266f2039408d600cfae7876dd4558c1811c..e1df436e80150b6f9e6e84cf5c4e818d404d613e 100644 (file)
@@ -562,6 +562,7 @@ gtk_grid_request_init (GtkGridRequest *request,
       lines->lines[i].minimum = 0;
       lines->lines[i].natural = 0;
       lines->lines[i].expand = FALSE;
+      lines->lines[i].empty = TRUE;
     }
 
   for (list = priv->children; list; list = list->next)
@@ -569,8 +570,18 @@ gtk_grid_request_init (GtkGridRequest *request,
       child = list->data;
 
       attach = &child->attach[orientation];
-      if (attach->span == 1 && gtk_widget_compute_expand (child->widget, orientation))
+      if (attach->span != 1)
+        continue;
+      if (gtk_widget_compute_expand (child->widget, orientation))
         lines->lines[attach->pos - lines->min].expand = TRUE;
+
+      lines->lines[attach->pos - lines->min].empty = FALSE;
+    }
+
+  for (i = 0; i < lines->max - lines->min; i++)
+    {
+      if (lines->lines[i].empty)
+        lines->lines[i].expand = TRUE;
     }
 }
 
@@ -903,6 +914,8 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
       for (i = 0; i < attach->span; i++)
         {
           line = &lines->lines[attach->pos - lines->min + i];
+          if (line->empty)
+            line->expand = TRUE;
           line->empty = FALSE;
           if (line->expand)
             has_expand = TRUE;